/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.lib.database;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import tmp.ac.options.DataBase;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 *
 * @author ismail
 */
public class dbconnection {

    public String retuenErrorMessage = "--";
    public String retuenuseData = "--";
    public String retuensqlString;
    public int retuenstatus=0;

  public  Connection con;
    String sql;
    ResultSet rs;
    Statement st;
    ResultSetMetaData resMetaData;

    private int BUFFER = 99999;

       ac.uitls.propertiesOperation op = new ac.uitls.propertiesOperation();

       
       
       protected  String DBName = op.getProperty("DBname");
       
       protected String connectionString = "jdbc:mysql://" + op.getProperty("DBHost") + "/" + DBName+"?useUnicode=true&characterEncoding=utf8";
           protected     String DBUser = op.getProperty("DBUser");
     protected   String DBPassword = op.getProperty("DBPassword");
    
    
    
    public String setOpenCon() {

     
       

        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(connectionString, DBUser, DBPassword);
        } catch (SQLException ex) {
            retuenErrorMessage += ex.getMessage();
            Logger.getLogger(dbconnection.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            retuenErrorMessage += ex.getMessage();
        }
        return retuenErrorMessage;
    }

    public void setCloseCon() {
        try {
            if (rs != null) {
                rs.close();
                rs = null;
            }
            if (st != null) {
                st.close();
                st = null;
            }
            if (con != null) {
                con.close();
                con = null;
            }
        } catch (SQLException ex) {
            //utils.outPrint(response, ex.getMessage());
            retuenErrorMessage += ex.getMessage();
        }

    }

}
